import { useIntersectionObserver } from '@vueuse/core';

/**
 * @description: 组件（数据）懒加载
 * @param {HTMLDivElement} target
 * @param {function} cb
 * @return {*}
 */
export const useLazyData = (target: HTMLDivElement | null, cb: () => void): any => {
    const { stop } = useIntersectionObserver(target, ([{ isIntersecting }]) => {
        if (isIntersecting) {
            stop();
            cb && cb();
        }
    });
};
